home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F25412_ShowTrimR.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  2.7 KB  |  75 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       Recursion
  4.   Author:         David Silverlight
  5.                   HeadGeek@xmlpitstop.com
  6.   Created:        2001-05-16
  7.   Description:-
  8.     This stylsheet demonstrates recursion by removing the
  9.     trailing(rightmost) spaces from an element.
  10.     Note: Since the    output is in HTML, you will need to view the
  11.     source of the HTML to see the differences bewtween the
  12.     trimmed and non-trimmed values.
  13. ================================================================ -->
  14. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  15.   <xsl:output method="html" indent="yes" />
  16.  
  17.   <xsl:include href="TrimR.xsl" />
  18.  
  19.   <xsl:template match="/">
  20.     <html>
  21.       <head>
  22.         <title>Stylesheet Example</title>
  23.         <style type="text/css"><![CDATA[
  24.         H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  25.         H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  26.         .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  27.         .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  28.         .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  29.         TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
  30.         TD {COLOR: darkblue; FONT-FAMILY: Arial}
  31.         TR { background-color: beige; }
  32.         BODY { background-color: beige; }
  33.         ]]></style>
  34.       </head>
  35.       <body>
  36.         <xsl:apply-templates />
  37.       </body>
  38.     </html>
  39.   </xsl:template>
  40.  
  41.   <xsl:template match="employees">
  42.     <h1>Employee listing with trailing spaces removed.</h1>
  43.     <!-- Table Header Creation -->
  44.     <table border="1">
  45.       <tr>
  46.         <th>Name</th>
  47.         <th>Department</th>
  48.         <th>Name(trimmed)</th>
  49.         <th>Department(trimmed)</th>
  50.       </tr>
  51.       <xsl:for-each select="employee">
  52.         <tr>
  53.           <td>
  54.             <xsl:value-of select="employeename" />
  55.           </td>
  56.           <td>
  57.             <xsl:value-of select="department" />
  58.           </td>
  59.           <td>
  60.             <!-- Call the template that will trim off trailing(rightmost) spaces (recursively, of course ) -->
  61.             <xsl:call-template name="TrimR">
  62.               <xsl:with-param name="strInput" select="employeename" />
  63.             </xsl:call-template>
  64.           </td>
  65.           <td>
  66.             <!-- Call the template that will trim off trailing(rightmost) spaces (recursively, of course ) -->
  67.             <xsl:call-template name="TrimR">
  68.               <xsl:with-param name="strInput" select="department" />
  69.             </xsl:call-template>
  70.           </td>
  71.         </tr>
  72.       </xsl:for-each>
  73.     </table>
  74.   </xsl:template>
  75. </xsl:stylesheet>